package com.caiju.health.service.impl;

import com.caiju.health.entity.PageResult;
import com.caiju.health.mapper.IOrderMapper;
import com.caiju.health.mapper.ITcmConstitutionIdentificationMapper;
import com.caiju.health.pojo.Order;
import com.caiju.health.pojo.TcmConstitutionIdentification;
import com.caiju.health.service.ITcmConstitutionIdentificationService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class TcmConstitutionIdentificationServiceImpl implements ITcmConstitutionIdentificationService {

    @Resource
    private ITcmConstitutionIdentificationMapper tcmConstitutionIdentificationMapper;

    @Override
    public PageResult findOrderItemByCondition(Integer currentPage, Integer pageSize, String queryString) {
        if (currentPage==null){
            currentPage = 1;
        }
        if (pageSize==null){
            pageSize = 5;
        }
        Page<Object> page = PageHelper.startPage(currentPage,pageSize);
//        queryString="null" ,误以为有值
        if(queryString.equals("null")){
            queryString = null;
        }else {
            queryString = "%" + queryString + "%";
        }
        List<TcmConstitutionIdentification> tcmConstitutionIdentificationList = tcmConstitutionIdentificationMapper.findCondition(queryString);
        PageResult pageResult = new PageResult(page.getTotal(),tcmConstitutionIdentificationList);
        return  pageResult;
}

    @Override
    public void deleteTcmConstitutionIdentificationById(Integer id) {
        tcmConstitutionIdentificationMapper.deleteTcmConstitutionIdentificationById(id);
    }
}
